﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace shopform
{
    public partial class NewClientForm : Form
    {
        public NewClientForm()
        {
            InitializeComponent();
        }

        private void ButtonSave_Click(object sender, EventArgs e)
        {
            try
            {
                Company c = new Company();
                
                c.CompanyAddr = this.TBCompanyAddress.Text;
                c.CompanyBusinessNumber = this.TBCompanyBusinessNumber.Text;
                c.CompanyCity = this.TBCompanyCity.Text;
                c.CompanyCountry = this.TBCompanyCountry.Text;
                c.CompanyID = this.TBCompanyIndex.Text;
                c.CompanyName = this.TBCompanyName.Text;
                c.CompanyPostCode = this.TBCompanyPostalCode.Text;
                c.CompanyRequestedLanguage = 
                          (int) Int32.Parse(this.CBDesiredLanguage.SelectedValue.ToString());

                c.insertCompany();
                MessageBox.Show("Kliens sikeresen regisztralva!");
                this.Close();
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }

        private void ButtonDiscard_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void CBDesiredLanguage_Populate()
        {
            Language l = new Language();

            this.CBDesiredLanguage.DataSource = l.Languages;
            this.CBDesiredLanguage.DisplayMember = "Text";
            this.CBDesiredLanguage.ValueMember = "Key";
        }

        private void NewClientForm_Load(object sender, EventArgs e)
        {
            this.CBDesiredLanguage_Populate();
        }

    }
}
